Fix #413, added methods TryMakeGenericType(s) #414
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The methods
TryMakeGenericType
/TryMakeGenericTypes
will attempt to construct a generic type for a given type/collection of types. In case of non-generic types, or generic types that were already constructed they'll be returned as-is.The method will attempt to find types that matches all generic constraints defined by the type itself, and if successful - call
Type.MakeGenericType
with the results.In case we encounter a generic type with constraints no types can match an error will be displayed (unless
ignoreErrors
argument will be passed and set to true). The only exception is abstract classes with no subclasses, for which no error will be shown (assuming here they are unused).The method was applied where needed. With RimWorld assembly itself, and majority of mods - this is going to do nothing. However, in case of mods that utilize generic types for the types that we end up patching - it should allow for those mods to properly work with Multiplayer without significantly breaking everything - for example, it should fix startup issues with Project Rimfactory.
As for error handling - I'm not 100% sure here. Perhaps adding
Multiplayer.loadingErrors = true
if errors are encountered? I can make changes where needed.And finally - I've attempted to add XML documentation, as well as some comments to the code to explain it a bit more. However, I'm not completely satisfied with it... If there's any changes that should be made, let me know.